package org.dromara.dp.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import org.dromara.common.core.domain.R;
import org.dromara.dp.vo.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 屏障完好性
 */
@RestController
@SaIgnore
@RequestMapping("/barrierIntegrity")
public class BarrierIntegrityController {

    /**
     * 安全指数趋势
     *
     * @param equipmentId
     * @return
     */
    @GetMapping("/safetyTrend")
    public R<SafetyTrendVo> getSafetyTrend(@RequestParam Long equipmentId) {
        SafetyTrendVo safetyTrendVo = new SafetyTrendVo();
        safetyTrendVo.setInitRiskCount(4);
        safetyTrendVo.setInitLowRiskCount(0);
        safetyTrendVo.setInitNormalRiskCount(0);
        safetyTrendVo.setInitMajorRiskCount(2);
        safetyTrendVo.setInitFatalRiskCount(2);

        safetyTrendVo.setResidualRiskCount(4);
        safetyTrendVo.setResidualLowRiskCount(0);
        safetyTrendVo.setResidualNormalRiskCount(2);
        safetyTrendVo.setResidualMajorRiskCount(2);
        safetyTrendVo.setResidualFatalRiskCount(0);

        SafetyTrendEventVo eventVo = new SafetyTrendEventVo();
        eventVo.setEventId(1L);
        eventVo.setEventName("甲醇V-9701甲醇缓冲罐泄漏");
        eventVo.setInitEventName("甲醇缓冲罐进料阀LV970101故障全开");
        eventVo.setFrequency("0.1");
        eventVo.setInitRiskLevel(3);
        eventVo.setReducedRiskLevel(2);
        eventVo.setResult("人员中毒");

        SafetyTrendEventVo eventVo1 = new SafetyTrendEventVo();
        eventVo.setEventId(2L);
        eventVo1.setEventName("甲醇V-9701甲醇缓冲罐泄漏");
        eventVo1.setInitEventName("甲醇缓冲罐出料泵P9701故障停");
        eventVo1.setFrequency("0.1");
        eventVo1.setInitRiskLevel(3);
        eventVo1.setReducedRiskLevel(2);
        eventVo1.setResult("火灾");

        SafetyTrendEventVo eventVo2 = new SafetyTrendEventVo();
        eventVo.setEventId(3L);
        eventVo2.setEventName("甲醇V-9701甲醇缓冲罐泄漏");
        eventVo2.setInitEventName("FICQ-970104失效，导致FV-970102关闭");
        eventVo2.setFrequency("0.1");
        eventVo2.setInitRiskLevel(2);
        eventVo2.setReducedRiskLevel(1);
        eventVo2.setResult("火灾");

        SafetyTrendEventVo eventVo3 = new SafetyTrendEventVo();
        eventVo.setEventId(4L);
        eventVo3.setEventName("甲醇V-9701甲醇缓冲罐泄漏");
        eventVo3.setInitEventName("V9701顶部压力调节PIC-970101A故障导致PV970101A全开");
        eventVo3.setFrequency("0.1");
        eventVo3.setInitRiskLevel(2);
        eventVo3.setReducedRiskLevel(1);
        eventVo3.setResult("财产损失");
        List<SafetyTrendEventVo> events = List.of(eventVo, eventVo1, eventVo2, eventVo3);
        safetyTrendVo.setEvents(events);
        return R.ok(safetyTrendVo);
    }

    /**
     * 风险矩阵 0当前 1历史
     *
     * @return
     */
    @GetMapping("/riskMatrix")
    public R<Object> riskMatrix(@RequestParam Integer type) {
        Integer[][] level = {
            {0, 0, 0, 0, 0, 0, 0, 0, 1},
            {0, 0, 0, 0, 0, 0, 0, 1, 1},
            {0, 0, 0, 0, 0, 0, 1, 1, 2},
            {0, 0, 0, 0, 0, 1, 1, 2, 2},
            {0, 0, 0, 1, 1, 2, 2, 3, 3},
            {0, 0, 1, 1, 2, 2, 3, 3, 3},
            {0, 1, 1, 2, 2, 3, 3, 3, 3},
            {1, 1, 2, 2, 3, 3, 3, 3, 3}
        };
        Integer[][] value = {
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 3, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 2, 1, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0},
            {0, 0, 0, 0, 0, 0, 0, 0, 0}
        };
        RiskMatrixVo result = new RiskMatrixVo();
        result.setLevel(level);
        result.setCount(value);
        if (type == 0) {
            return R.ok(result);
        } else {
            Map<LocalDate, RiskMatrixVo> r = new HashMap<>();
            r.put(LocalDate.now(), result);
            r.put(LocalDate.now().plusDays(1), result);
            return R.ok(r);
        }
    }

    /**
     * 屏障列表
     *
     * @return
     */
    @GetMapping("/barrierList")
    public R<BarrierSummaryVo> barrierList() {
        BarrierInfoVo barrierInfoVo = new BarrierInfoVo(0, "PZ-001", "压力显示及高报警PICA970101", "甲醇制氢", "测试", 0);
        BarrierInfoVo barrierInfoVo1 = new BarrierInfoVo(0, "PZ-002", "设有液位LICA-970101显示及高报警", "甲醇制氢", "测试", 1);
        BarrierInfoVo barrierInfoVo2 = new BarrierInfoVo(1, "PZ-003", "设有液位LICA-970101显示及高报警", "甲醇制氢", "测试", 2);
        BarrierInfoVo barrierInfoVo3 = new BarrierInfoVo(1, "PZ-004", "设有安全阀SV-9701A/B", "甲醇制氢", "测试", 1);
        List<BarrierInfoVo> vos = List.of(barrierInfoVo, barrierInfoVo1, barrierInfoVo2, barrierInfoVo3);
        BarrierSummaryVo barrierSummaryVo = new BarrierSummaryVo();
        barrierSummaryVo.setBarrierInfoList(vos);
        barrierSummaryVo.setFailedBarrier(2);
        barrierSummaryVo.setDegradedBarrier(2);
        return R.ok(barrierSummaryVo);
    }

    /**
     * 屏障图
     *
     * @return
     */
    @GetMapping("/barrierMap")
    public R<NodeMapVo> barrierMap(@RequestParam Long eventId) {
        BarrierNodeVo f1 = new BarrierNodeVo();
        f1.setNodeId(1L);
        f1.setNodeName("甲醇缓冲罐进料阀LV970101故障全开");
        f1.setNodeType(1);

        BarrierNodeVo f2 = new BarrierNodeVo();
        f2.setNodeId(2L);
        f2.setNodeName("甲醇缓冲罐出料泵P9701故障停");
        f2.setNodeType(1);

        BarrierNodeVo f3 = new BarrierNodeVo();
        f3.setNodeId(3L);
        f3.setNodeName("FICQ-970104失效，导致FV-970102关闭");
        f3.setNodeType(1);

        BarrierNodeVo f4 = new BarrierNodeVo();
        f4.setNodeId(4L);
        f4.setNodeName("V9701顶部压力调节PIC-970101故障导致PV970101A全开");
        f4.setNodeType(1);

        BarrierNodeVo s1 = new BarrierNodeVo();
        s1.setNodeId(5L);
        s1.setNodeName("压力显示及高报警PICA970101");
        s1.setNodeType(2);
        s1.setType("关键报警和人员干预");
        s1.setPfd("0.8");
        s1.setDescription("醇缓冲罐压力控制设备，保护甲醇缓冲罐处于正常压力状态下");
        s1.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s1.setTag("预防性屏障");

        BarrierNodeVo s2 = new BarrierNodeVo();
        s2.setNodeId(6L);
        s2.setNodeName("设有液位LICA-970101显示及高报警");
        s2.setNodeType(2);
        s2.setType("关键报警和人员干预");
        s2.setDescription("甲醇输送泵液位控制器，控制甲醇管进出料情况");
        s2.setPfd("0.8");
        s2.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s2.setTag("预防性屏障");

        BarrierNodeVo s3 = new BarrierNodeVo();
        s3.setNodeId(7L);
        s3.setNodeName("设有液位LICA-970101显示及高报警");
        s3.setNodeType(2);
        s3.setType("关键报警和人员干预");
        s3.setDescription("甲醇缓冲罐液位控制设备，保护甲醇缓冲罐处于正常液位状态下。");
        s3.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s3.setTag("预防性屏障");

        BarrierNodeVo s4 = new BarrierNodeVo();
        s4.setNodeId(8L);
        s4.setNodeName("设有安全阀SV-9701A/B");
        s4.setNodeType(2);
        s4.setType("释放措施物理保护");
        s4.setDescription("甲醇缓冲罐压力释放措施");
        s4.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s4.setTag("预防性屏障");

        BarrierNodeVo t1 = new BarrierNodeVo();
        t1.setNodeId(9L);
        t1.setNodeName("设有安全阀SV-9701A/B");
        t1.setNodeType(2);
        t1.setDescription("甲醇缓冲罐压力释放措施");
        t1.setPfd("0.9");
        t1.setType("释放措施物理保护");
        t1.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        t1.setTag("预防性屏障");

        BarrierNodeVo t2 = new BarrierNodeVo();
        t2.setNodeId(10L);
        t2.setNodeName("设有PICA970102压力控制");
        t2.setNodeType(2);
        t2.setDescription("监测甲醇缓冲罐进出料压力系统");
        t2.setPfd("0.8");
        t2.setType("关键报警和人员干预");
        t2.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        t2.setTag("预防性屏障");

        BarrierNodeVo t3 = new BarrierNodeVo();
        t3.setNodeId(11L);
        t3.setNodeName("P9701泵出口设有压力；PICA970102压力显示及高报警");
        t3.setNodeType(2);
        t3.setDescription("醇缓冲罐压力控制设备，保护甲醇缓冲罐处于正常压力状态下。");
        t3.setType("关键报警和人员干预");
        t3.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        t3.setTag("预防性屏障");

        BarrierNodeVo f11 = new BarrierNodeVo();
        f11.setNodeId(12L);
        f11.setNodeName("设有液位LICA-970101显示及高报警");
        f11.setNodeType(2);
        f11.setDescription("甲醇缓冲罐液位控制设备，保护甲醇缓冲罐处于正常液位状态下。");
        f11.setPfd("0.8");
        f11.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        f11.setType("关键报警和人员干预");
        f11.setTag("预防性屏障");

        BarrierNodeVo f12 = new BarrierNodeVo();
        f12.setNodeId(13L);
        f12.setNodeName("设有安全阀SV-9701A/B");
        f12.setNodeType(2);
        f12.setDescription("甲醇缓冲罐压力释放措施");
        f12.setPfd("0.9");
        f12.setType("释放措施物理保护");
        f12.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        f12.setTag("预防性屏障");

        BarrierNodeVo f13 = new BarrierNodeVo();
        f13.setNodeId(14L);
        f13.setNodeName("压力显示及高报警PICA970101");
        f13.setNodeType(2);
        f13.setDescription("醇缓冲罐压力控制设备，保护甲醇缓冲罐处于正常压力状态下。");
        f13.setType("关键报警和人员干预");
        f13.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        f13.setTag("预防性屏障");

        BarrierNodeVo f21 = new BarrierNodeVo();
        f21.setNodeId(15L);
        f21.setNodeName("设有安全阀SV-9701A/B");
        f21.setNodeType(2);
        f21.setDescription("甲醇缓冲罐压力释放措施");
        f21.setType("释放措施物理保护");
        f21.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        f21.setTag("预防性屏障");

        BarrierNodeVo s11 = new BarrierNodeVo();
        s11.setNodeId(16L);
        s11.setNodeName("甲醇V-9701甲醇缓冲罐泄露");
        s11.setNodeType(3);

        BarrierNodeVo s21 = new BarrierNodeVo();
        s21.setNodeId(17L);
        s21.setNodeName("气体报警仪");
        s21.setNodeType(4);
        s21.setDescription("甲醇缓冲罐周围有毒可燃气体监测，有毒可燃气体泄露后可及时发现");
        s21.setType("");
        s21.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");


        BarrierNodeVo s22 = new BarrierNodeVo();
        s22.setNodeId(18L);
        s22.setNodeName("气体报警仪");
        s22.setNodeType(4);
        s22.setDescription("甲醇缓冲罐周围有毒可燃气体监测，有毒可燃气体泄露后可及时发现");
        s22.setType("应急措施");
        s22.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s22.setTag("消减性屏障");

        BarrierNodeVo s23 = new BarrierNodeVo();
        s23.setNodeId(19L);
        s23.setNodeName("气体报警仪");
        s23.setNodeType(4);
        s23.setDescription("甲醇缓冲罐周围有毒可燃气体监测，有毒可燃气体泄露后可及时发现");
        s23.setType("应急措施");
        s23.setDegradationFactor("1.设备老化与维护不足 2.控制系统失效 3.人为操作与培训缺失 4.工艺条件恶化");
        s23.setTag("消减性屏障");

        BarrierNodeVo e1 = new BarrierNodeVo();
        e1.setNodeId(20L);
        e1.setNodeName("应急演练/兼职消防队");
        e1.setNodeType(4);

        BarrierNodeVo e2 = new BarrierNodeVo();
        e2.setNodeId(21L);
        e2.setNodeName("火灾自动报警系统");
        e2.setNodeType(4);

        BarrierNodeVo e3 = new BarrierNodeVo();
        e3.setNodeId(22L);
        e3.setNodeName("火灾自动报警系统");
        e3.setNodeType(4);

        BarrierNodeVo n2 = new BarrierNodeVo();
        n2.setNodeId(24L);
        n2.setNodeName("消防系统");
        n2.setNodeType(4);

        BarrierNodeVo n3 = new BarrierNodeVo();
        n3.setNodeId(25L);
        n3.setNodeName("消防系统");
        n3.setNodeType(4);

        BarrierNodeVo t21 = new BarrierNodeVo();
        t21.setNodeId(31L);
        t21.setNodeName("人员中毒");
        t21.setNodeType(5);

        BarrierNodeVo t22 = new BarrierNodeVo();
        t22.setNodeId(32L);
        t22.setNodeName("火灾");
        t22.setNodeType(5);

        BarrierNodeVo t23 = new BarrierNodeVo();
        t23.setNodeId(33L);
        t23.setNodeName("财产损失");
        t23.setNodeType(5);
        List<BarrierNodeVo> nodes = List.of(f1, f2, f3, f4, s1, s2, s3, s4, t1, t2, t3, f11, f12, f13, f21, s11, s21, s22, s23, e1, e2, e3, n2, n3, t21, t22, t23);

        NodeRelationVo relation1 = new NodeRelationVo(f1.getNodeId(), s1.getNodeId());
        NodeRelationVo relation2 = new NodeRelationVo(f2.getNodeId(), s2.getNodeId());
        NodeRelationVo relation3 = new NodeRelationVo(f3.getNodeId(), s3.getNodeId());
        NodeRelationVo relation4 = new NodeRelationVo(f4.getNodeId(), s4.getNodeId());
        NodeRelationVo relation5 = new NodeRelationVo(s1.getNodeId(), t1.getNodeId());
        NodeRelationVo relation6 = new NodeRelationVo(s2.getNodeId(), t2.getNodeId());
        NodeRelationVo relation7 = new NodeRelationVo(s3.getNodeId(), t3.getNodeId());
        NodeRelationVo relation8 = new NodeRelationVo(s4.getNodeId(), s11.getNodeId());
        NodeRelationVo relation9 = new NodeRelationVo(t1.getNodeId(), f11.getNodeId());
        NodeRelationVo relation10 = new NodeRelationVo(t2.getNodeId(), f12.getNodeId());
        NodeRelationVo relation11 = new NodeRelationVo(t3.getNodeId(), f13.getNodeId());
        NodeRelationVo relation12 = new NodeRelationVo(f11.getNodeId(), s11.getNodeId());
        NodeRelationVo relation13 = new NodeRelationVo(f12.getNodeId(), s11.getNodeId());
        NodeRelationVo relation14 = new NodeRelationVo(f13.getNodeId(), f21.getNodeId());
        NodeRelationVo relation15 = new NodeRelationVo(s11.getNodeId(), s21.getNodeId());
        NodeRelationVo relation16 = new NodeRelationVo(s11.getNodeId(), s22.getNodeId());
        NodeRelationVo relation17 = new NodeRelationVo(s11.getNodeId(), s23.getNodeId());
        NodeRelationVo relation18 = new NodeRelationVo(s21.getNodeId(), e1.getNodeId());
        NodeRelationVo relation19 = new NodeRelationVo(s22.getNodeId(), e2.getNodeId());
        NodeRelationVo relation20 = new NodeRelationVo(s23.getNodeId(), e3.getNodeId());
        NodeRelationVo relation21 = new NodeRelationVo(e1.getNodeId(), t21.getNodeId());
        NodeRelationVo relation22 = new NodeRelationVo(e2.getNodeId(), n2.getNodeId());
        NodeRelationVo relation23 = new NodeRelationVo(e3.getNodeId(), n3.getNodeId());
        NodeRelationVo relation25 = new NodeRelationVo(n2.getNodeId(), t22.getNodeId());
        NodeRelationVo relation26 = new NodeRelationVo(n3.getNodeId(), t23.getNodeId());
        NodeRelationVo relation32 = new NodeRelationVo(f21.getNodeId(), s11.getNodeId());

        List<NodeRelationVo> relationVos = List.of(relation1, relation2, relation3, relation4, relation5,
            relation6, relation7, relation8, relation9, relation10, relation11, relation12, relation13, relation14,
            relation15, relation16, relation17, relation18, relation19, relation20, relation21, relation22,
            relation23, relation25, relation26, relation32);
        NodeMapVo nodeMapVo = new NodeMapVo();
        nodeMapVo.setNodes(nodes);
        nodeMapVo.setRelations(relationVos);
        return R.ok(nodeMapVo);
    }

    /**
     * 链路报警
     *
     * @param equipmentId 设备id
     * @return
     * @Param date  日期
     * @Param code  位号
     */
    @GetMapping("/chainAlarm")
    public R<List<NodeAlarmVo>> chainAlarm(Long equipmentId, String code) {
        // 3红 2 黄 1蓝 0灰
        RiskAlarmVo riskAlarmVo = new RiskAlarmVo(1L, "LV970101", 3, "20.6", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 10000L, "甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo1 = new RiskAlarmVo(2L, "PICA970101", 1, "78.9", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 3500L, "二氧化碳压缩机压力高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo11 = new RiskAlarmVo(21L, "PICA970101", 1, "78.9", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 3500L, "二氧化碳压缩机压力高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        List<String> strings = List.of("2:2:2", "0:2:1", "4:5:1");
        riskAlarmVo.setInitData(strings);
        riskAlarmVo1.setInitData(strings);
        riskAlarmVo11.setInitData(strings);
        riskAlarmVo.setCanyuData("3:4");
        riskAlarmVo1.setCanyuData("3:4");
        riskAlarmVo11.setCanyuData("3:4");

        NodeAlarmVo nodeAlarmVo = new NodeAlarmVo(5L, riskAlarmVo);
        NodeAlarmVo nodeAlarmVo1 = new NodeAlarmVo(9L, riskAlarmVo1);
        NodeAlarmVo nodeAlarmVo11 = new NodeAlarmVo(12L, riskAlarmVo11);

        RiskAlarmVo riskAlarmVo2 = new RiskAlarmVo(3L, "SV-9701A/B", 1, "6.3", 3, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), (long) (60 * 60 + 2 * 60), "甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo3 = new RiskAlarmVo(4L, "PI-972007B", 3, "78.0", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), 2500L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo31 = new RiskAlarmVo(41L, "PI-972007B", 2, "78.0", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), 2500L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        List<String> strings1 = List.of("2:3:2", "0:3:1", "5:5:1");
        riskAlarmVo2.setInitData(strings1);
        riskAlarmVo3.setInitData(strings1);
        riskAlarmVo31.setInitData(strings1);
        riskAlarmVo2.setCanyuData("4:5");
        riskAlarmVo3.setCanyuData("4:5");
        riskAlarmVo31.setCanyuData("4:5");

        NodeAlarmVo nodeAlarmVo2 = new NodeAlarmVo(6L, riskAlarmVo2);
        NodeAlarmVo nodeAlarmVo3 = new NodeAlarmVo(10L, riskAlarmVo3);
        NodeAlarmVo nodeAlarmVo31 = new NodeAlarmVo(13L, riskAlarmVo31);

        RiskAlarmVo riskAlarmVo5 = new RiskAlarmVo(6L, "P9701", 0, "23.0", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 5000L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo6 = new RiskAlarmVo(7L, "LICA970101", 3, "17.0", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 60000L, "2025年11月11日08时35分V-970101液位升高超过报警阈值报警报警点位(LIC-970101 报警值81% 报警阈值80%)", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        RiskAlarmVo riskAlarmVo7 = new RiskAlarmVo(8L, "PICA970102", 2, "48.0", 3, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 60000L, "08时40分 液位持续上升 LI-970303 高报警(报警点位 LI-970303 报警值 90.5% 报警阈值 90%)可", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
        List<String> strings2 = List.of("2:4:3", "5:6:1");
        riskAlarmVo5.setInitData(strings2);
        riskAlarmVo6.setInitData(strings2);
        riskAlarmVo7.setInitData(strings2);
        riskAlarmVo5.setCanyuData("5:6");
        riskAlarmVo6.setCanyuData("5:6");
        riskAlarmVo7.setCanyuData("5:6");


        NodeAlarmVo nodeAlarmVo5 = new NodeAlarmVo(6L, riskAlarmVo5);
        NodeAlarmVo nodeAlarmVo6 = new NodeAlarmVo(10L, riskAlarmVo6);
        NodeAlarmVo nodeAlarmVo7 = new NodeAlarmVo(13L, riskAlarmVo7);
        return R.ok(List.of(nodeAlarmVo, nodeAlarmVo1, nodeAlarmVo2, nodeAlarmVo3, nodeAlarmVo5, nodeAlarmVo6, nodeAlarmVo7, nodeAlarmVo11, nodeAlarmVo31));
    }


    /**
     * 坐标关联报警
     *
     * @param index
     * @return
     * @Param date  日期
     * @Param code  位号
     */
    @GetMapping("/getIndexAlarm")
    public R<List<NodeAlarmVo>> getIndexAlarm(String index) {
        List<String> strings = List.of("2:2:2", "0:2:1", "4:5:1", "3:4");
        if (strings.contains(index)) {
            RiskAlarmVo riskAlarmVo = new RiskAlarmVo(1L, "LV970101", 3, "20.6", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 10000L, "甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo1 = new RiskAlarmVo(2L, "PICA970101", 1, "78.9", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 3500L, "二氧化碳压缩机压力高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo11 = new RiskAlarmVo(21L, "PICA970101", 1, "78.9", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 35)), 3500L, "二氧化碳压缩机压力高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            riskAlarmVo.setInitData(strings);
            riskAlarmVo1.setInitData(strings);
            riskAlarmVo11.setInitData(strings);
            riskAlarmVo.setCanyuData("3:4");
            riskAlarmVo1.setCanyuData("3:4");
            riskAlarmVo11.setCanyuData("3:4");

            NodeAlarmVo nodeAlarmVo = new NodeAlarmVo(5L, riskAlarmVo);
            NodeAlarmVo nodeAlarmVo1 = new NodeAlarmVo(9L, riskAlarmVo1);
            NodeAlarmVo nodeAlarmVo11 = new NodeAlarmVo(12L, riskAlarmVo11);
            return R.ok(List.of(nodeAlarmVo, nodeAlarmVo1, nodeAlarmVo11));
        }
        List<String> strings1 = List.of("2:3:2", "0:3:1", "5:5:1", "4:5");
        if (strings1.contains(index)) {
            RiskAlarmVo riskAlarmVo2 = new RiskAlarmVo(3L, "SV-9701A/B", 1, "6.3", 3, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), (long) (60 * 60 + 2 * 60), "甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo3 = new RiskAlarmVo(4L, "PI-972007B", 3, "78.0", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), 2500L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo31 = new RiskAlarmVo(41L, "PI-972007B", 2, "78.0", 4, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 40)), 2500L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            riskAlarmVo2.setInitData(strings1);
            riskAlarmVo3.setInitData(strings1);
            riskAlarmVo31.setInitData(strings1);
            riskAlarmVo2.setCanyuData("4:5");
            riskAlarmVo3.setCanyuData("4:5");
            riskAlarmVo31.setCanyuData("4:5");

            NodeAlarmVo nodeAlarmVo2 = new NodeAlarmVo(6L, riskAlarmVo2);
            NodeAlarmVo nodeAlarmVo3 = new NodeAlarmVo(10L, riskAlarmVo3);
            NodeAlarmVo nodeAlarmVo31 = new NodeAlarmVo(13L, riskAlarmVo31);
            return R.ok(List.of(nodeAlarmVo2, nodeAlarmVo3, nodeAlarmVo31));
        }
        List<String> strings2 = List.of("2:4:3", "5:6:1", "5:6");
        if (strings2.contains(index)) {
            RiskAlarmVo riskAlarmVo5 = new RiskAlarmVo(6L, "P9701", 0, "23.0", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 5000L, " 甲醇缓冲罐液位高高报到连锁值", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo6 = new RiskAlarmVo(7L, "LICA970101", 3, "17.0", 1, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 60000L, "2025年11月11日08时35分V-970101液位升高超过报警阈值报警报警点位(LIC-970101 报警值81% 报警阈值80%)", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            RiskAlarmVo riskAlarmVo7 = new RiskAlarmVo(8L, "PICA970102", 2, "48.0", 3, LocalDateTime.of(LocalDate.now(), LocalTime.of(8, 45)), 60000L, "08时40分 液位持续上升 LI-970303 高报警(报警点位 LI-970303 报警值 90.5% 报警阈值 90%)可", "LICA970101", "LICA970101（液位指示调节报警仪表设备）故障");
            riskAlarmVo5.setInitData(strings2);
            riskAlarmVo6.setInitData(strings2);
            riskAlarmVo7.setInitData(strings2);
            riskAlarmVo5.setCanyuData("5:6");
            riskAlarmVo6.setCanyuData("5:6");
            riskAlarmVo7.setCanyuData("5:6");

            NodeAlarmVo nodeAlarmVo5 = new NodeAlarmVo(6L, riskAlarmVo5);
            NodeAlarmVo nodeAlarmVo6 = new NodeAlarmVo(10L, riskAlarmVo6);
            NodeAlarmVo nodeAlarmVo7 = new NodeAlarmVo(13L, riskAlarmVo7);
            return R.ok(List.of(nodeAlarmVo5, nodeAlarmVo6, nodeAlarmVo7));
        }
        return R.ok();
    }
}
